package com.bolt.admin.module.sys.entity;

import com.bolt.support.spring.jpa.entity.BaseUuidEntity;
import lombok.Data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;


@Access(AccessType.FIELD)
@Entity
@Table(name = "SYS_ROLER2PRIVILEGE", uniqueConstraints = @UniqueConstraint(columnNames = {"privilege_id", "role_id"}))
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Data
public class RoleR2Privilege extends BaseUuidEntity {

    private static final long serialVersionUID = -4312077296555510354L;

    /**
     * 关联权限对象
     */
    @ManyToOne
    @JoinColumn(name = "privilege_id", nullable = false)
    private PrivilegeEntity privilege;

    /**
     * 关联角色对象
     */
    @ManyToOne
    @JoinColumn(name = "role_id", nullable = false)
    private RoleEntity role;

    @Column(name = "privilege_id", updatable = false, insertable = false)
    private String privilegeId;

    @Column(name = "role_id", updatable = false, insertable = false)
    private String roleId;
}

